package com.yunying.rispro.util;

import lombok.Data;

/**
 * 响应封装类，用于定义统一的返回结果
 * @param <T>
 */
@Data
public class JsonResponseBody<T> {

    // 状态码
    private int code;
    // 状态信息
    private String msg;
    // 响应数据
    private T data;
    // 分页总记录数
    private long total;

    public JsonResponseBody(){
        this.code=JsonResponseStatus.SUCCESS.getCode();
        this.msg=JsonResponseStatus.SUCCESS.getMsg();
    }

    public JsonResponseBody(JsonResponseStatus jsonResponseStatus){
        this.code=jsonResponseStatus.getCode();
        this.msg=jsonResponseStatus.getMsg();
    }

    public JsonResponseBody(T data){
        this.code=JsonResponseStatus.SUCCESS.getCode();
        this.msg=JsonResponseStatus.SUCCESS.getMsg();
        this.data=data;
    }

    public JsonResponseBody(T data,long total){
        this.code=JsonResponseStatus.SUCCESS.getCode();
        this.msg=JsonResponseStatus.SUCCESS.getMsg();
        this.data=data;
        this.total=total;
    }
}
